function call
Học thuậtThân thiện
Definition
- Noun:
- A specific instruction in a computer program: A "function call" is an instruction that transfers execution to a defined subroutine or function. After the subroutine completes its task, execution returns to the point immediately following the call in the main program.
Usage
- A "function call" is a fundamental concept in programming. It involves using the name of a function, often with arguments enclosed in parentheses, to execute the code within that function.
- It represents the invocation or activation of a function's code block from another part of the program.
Examples
- Noun:
- The program's efficiency improved after optimizing the frequent
function callwithin the loop. - A
function calllikecalculateTotal(price, tax)passes the control to thecalculateTotalsubroutine. - Debugging often involves tracing the sequence of
function callsto find where an error occurs.
Advanced Usage
- Nested Function Call: A "function call" where the argument for one call is the result of another call.
print(sqrt(25))is an example of a nestedfunction callwheresqrt(25)is evaluated first.
- Recursive Function Call: A special case where a function calls itself as part of its execution.
- The factorial algorithm uses a recursive
function callto solve the problem.
Variants and Related Words
- Call (verb/noun): In programming, to invoke a subroutine. The "function call" is the specific instance of this action.
- Subroutine Call / Procedure Call: Terms often used synonymously with "function call," though they may imply slight differences in language semantics (e.g., a procedure might not return a value).
- Invocation: A more formal term for the act of calling a function or subroutine.
Synonyms
- Subroutine invocation
- Procedure call
- Method call (in object-oriented programming)
Related Phrases
- Function Call Stack (Call Stack): A data structure that stores information about the active , tracking the point to which each should return control.
- An overflow error can occur if too many recursive
function callsfill thecall stack.
- Function Call Overhead: The extra computational resources (time, memory) required to make a , including passing arguments and managing the call stack.
- Inlining small functions can reduce
function call overhead.
Notes
- The term is specific to computer science and programming. The "call" in "function call" is metaphorical, based on the idea of calling upon a subroutine to perform a service.
- The structure and syntax of a "function call" vary between programming languages (e.g., in C/Java, in Haskell).
Noun
- a call that passes control to a subroutine; after the subroutine is executed control returns to the next instruction in main program